package com.nbsaas.boot.entity.evaluate;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.CatalogEntity;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.io.Serializable;
import java.util.List;

/**
 * 评价分类
 * 
 * @author 系统生成
 */
@Comment("评价分类")
@CatalogClass
@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "评价分类管理", model = "评价分类", searchWidth = "100", viewWidth = "120")
@Entity
@Table(name = "bs_evaluate_catalog")
public class EvaluateCatalog extends CatalogEntity {

    @Comment("父分类")
    @FieldName
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private EvaluateCatalog parent;

    @Comment("子分类列表")
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent")
    private List<EvaluateCatalog> children;

    @Comment("该分类下评价数量")
    private Long evaluateCount;

    @Comment("分类图标")
    @FormField(title = "分类图标", sortNum = "30", grid = true)
    @Column(length = 50)
    private String icon;

    @Comment("分类描述")
    @FormField(title = "分类描述", sortNum = "40", grid = true, type = InputType.textarea)
    @Column(length = 500)
    private String description;

    @Override
    public Serializable getParentId() {
        if (parent != null) {
            return parent.getId();
        }
        return null;
    }
} 